package org.luckyjourney.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

// 分片类，存储redis中id生成器当前的id值和数量
@Data
public class Sharding{
    // 可用分片id
    private Long id;

    // 最大存储数量
    private Long max;

    // 当前已存储数量
    private Long size;

    public Sharding(Long id, Long count, Long max) {
        this.id = id;
        this.size = count;
        this.max = max;
    }


    public boolean isFull(){
        return size == max;
    }

    public boolean increment(){
        if(isFull()) return false;
        size++;
        return true;
    }
}